<html>
    <head>
        <script src="incppect.js"></script>
    </head>

    <body>
        <h3>Incppect example: hello-browser-ssl</h3>

        <script>
            function init() {
                // create output element
                var output = document.createElement('div');
                document.body.appendChild( output );

                // define incppect client functions
                incppect.render = function() {
                    // print some C++ variables
                    output.innerHTML = '';
                    output.innerHTML += 'var_int8 = ' + this.get_int8('var_int8') + '<br>';
                    output.innerHTML += 'var_int16 = ' + this.get_int16('var_int16') + '<br>';
                    output.innerHTML += 'var_int32 = ' + this.get_int32('var_int32') + '<br>';
                    output.innerHTML += 'var_int32_arr = ' + this.get_int32_arr('var_int32_arr') + '<br>';
                    output.innerHTML += 'var_int32_arr[2] = ' + this.get_int32_arr('var_int32_arr[%d]', 2) + '<br>';
                    output.innerHTML += 'var_float = ' + this.get_float('var_float') + '<br>';
                    output.innerHTML += 'var_double = ' + this.get_double('var_double') + '<br>';
                    output.innerHTML += 'var_str = ' + this.get_str('var_str') + '<br>';
                }

                incppect.onerror = function(evt) {
                    if (typeof evt === 'object') {
                        output.innerHTML = 'Error: check console for more information';
                        console.error(evt);
                    } else {
                        output.innerHTML = evt;
                    }
                }

                // initialize incppect client
                incppect.init();
            }

            incppect.ws_uri = 'wss://' + window.location.hostname + ':' + window.location.port + '/incppect';

            init();
        </script>
    </body>
</html>
